package com.sud.framework.system.listener;

import com.sud.framework.system.utils.SpringUtil;
import org.apache.log4j.Logger;
import org.springframework.web.context.ContextLoaderListener;
import org.springframework.web.context.WebApplicationContext;

import javax.servlet.ServletContextEvent;

/**
 * 功能：系统初始化监听
 * 作者：SUD
 * 时间：2015/12/2 13:43
 */
public class InitListener extends ContextLoaderListener//implements ServletContextListener
{
    private static final Logger log = Logger.getLogger(InitListener.class);

    public void contextInitialized(ServletContextEvent event) {
        log.info("init SpringUtils.........");
        super.contextInitialized(event);
        //ServletContext context = event.getServletContext();
        WebApplicationContext ctx = getCurrentWebApplicationContext();
        //WebApplicationContextUtils.getRequiredWebApplicationContext(context);
        SpringUtil.setApplicationContext(ctx);

        log.info("init SpringUtils.........");
    }

    public void contextDestroyed(ServletContextEvent arg0) {
        super.contextDestroyed(arg0);
    }

}